<template>
	<div class="wrap">
		<div class="answer-bot">
			<el-table :data="tableData" stripe border>
				<el-table-column
					label="用户编号"
					prop="member_id"
					min-width="120px"
					show-overflow-tooltip
					align="center"
				/>
				<el-table-column
					label="用户手机号"
					prop="sms_send_phone"
					min-width="120px"
					show-overflow-tooltip
					align="center"
				/>
				<el-table-column
					label="消息标题"
					prop="msg_title"
					min-width="180px"
					show-overflow-tooltip
					align="center"
				/>
				<el-table-column
					label="消息内容"
					min-width="180px"
					show-overflow-tooltip
					align="center"
					:formatter="
						row => (JSON.stringify(row.msg_data) == '[]' ? '--' : JSON.stringify(row.msg_data))
					"
				/>
				<el-table-column
					label="发送状态"
					min-width="180px"
					show-overflow-tooltip
					align="center"
					:formatter="
						row =>
							row.sms_send == 1
								? '发送成功'
								: row.sms_send == 2
								? '发送失败'
								: row.sms_send == 3
								? '已发送'
								: '未发送'
					"
				/>
				<el-table-column
					label="发送时间"
					prop="add_time"
					min-width="120px"
					show-overflow-tooltip
					align="center"
				/>
			</el-table>
			<el-row type="flex" justify="center">
				<el-col :span="24" style="text-align: right">
					<Pagination
						:total="total"
						:page.sync="pageNo"
						:limit.sync="pageSize"
						scroll-el="el-main"
						@pagination="pageChange"
					/>
				</el-col>
			</el-row>
		</div>
	</div>
</template>

<script>
	import { sendLists } from '@/api/user-manager'
	import Pagination from '@/components/Pagination'
	export default {
		components: { Pagination },
		data() {
			return {
				pageNo: 1,
				pageSize: 10,
				total: 0,
				tableData: []
			}
		},
		created() {
			this.searchData()
		},
		methods: {
			// 搜索
			searchData() {
				this.pageNo = 1
				this.loadData()
			},
			// 分页
			pageChange({ page, limit }) {
				this.pageNo = page
				this.pageSize = limit
				this.loadData()
			},
			loadData() {
				const loading = this.$setLoading()
				this.tableData = []
				sendLists({
					page_no: this.pageNo,
					page_size: this.pageSize
				}).then(
					res => {
						this.tableData = res.data.lists
						this.total = Number(res.data.total)
						loading.close()
					},
					err => {
						loading.close()
					}
				)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.app-container {
		.roles-table {
			margin-top: 30px;
		}

		.tree-label {
			font-size: 14px;
			color: #606266;
			font-weight: bolder;
			padding-left: 9px;
		}

		.permission-tree {
			margin: 30px;
		}
	}

	.el-link {
		margin-right: 16px;
	}
	.form {
		background: #ffffff;
		padding: 20px 10px 0;
		margin-bottom: 10px;
		border-radius: 2px;
		display: flex;
		flex-wrap: wrap;
	}
	.line {
		height: 36px;
		margin: 0 0 10px 18px;
		border-left: 1px solid #e5e6eb !important;
		padding: 0 0 0 18px;
	}
	.answer-bot {
		padding: 16px;
		border-radius: 2px;
		background-color: #ffffff;
		.bot-title {
			font-size: 16px;
			font-family: PingFangSC-Regular, PingFang SC;
			color: #000000;
		}
	}
</style>
